<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
  <!-- import CSS -->
  <link rel="stylesheet" href="css/eui.css">
  <style>
      body {
          margin: 0;
          background-image: url("imgs/23.jpg");
          background-size: cover; /*cover是专门用来设置全屏背景的*/
          text-align: center;
      }
    img{
      width: 100px;
    }
  </style>
</head>
<body>
<div id="app" style="margin: 250px 0px 0px 0px">
    <el-card style="width: 600px;height: 300px;
    margin: 0 auto;background-color: white;background-image: url('imgs/24.jpg')">
        <el-form style="width: 400px;margin: 30px auto" label-width="60px">
            <h3>管理员登陆</h3>
            <el-form-item label="用户名">
                <el-input type="text" v-model="admin.username" placeholder="请输入用户名"></el-input>
            </el-form-item>
            <el-form-item label="密码">
                <el-input type="password" v-model="admin.password" placeholder="请输入密码"></el-input>
            </el-form-item>
            <el-form-item>
                <el-button style="position: relative;right: 20px" type="primary" @click="login()">登录</el-button>
            </el-form-item>
        </el-form>
    </el-card>
</div>
</body>
<script src="js/vue.js"></script>
<script src="js/eui.js"></script>
<script src="js/axios.min.js"></script>
<script>
    let v=new Vue({
        //设置影响的范围
        el:"div",
        //设置动态的数据
        data:{
            admin:{
                    username:"",
                    password:""
                }
            },
        methods:{
            login() {
                //发布异步post请求
                axios.post("/login",v.admin).then(function (response){
                    if(response.data==1){
                        alert("登录成功!");
                        location.href="/admin.html";
                    }else if (response.data==2){
                        alert("用户名不存在!");
                    }else{
                        alert("密码错误!");
                    }
                })
            }
        }
    })
</script>
</html>